package cn.egame.extraction.dao;

import java.util.ArrayList;
import java.util.List;

import cn.egame.common.data.BaseDao;
import cn.egame.common.exception.ExceptionCommonBase;
import cn.egame.common.util.Utils;

public class UserGameDao extends BaseDao {

    public UserGameDao() throws ExceptionCommonBase {
        super("egame_comment");
    }

    
    public List<Long> listUId() throws ExceptionCommonBase {
        String sql = "select distinct u_id from t_user_game ";
        return this.getListLong(sql);
    }
    
    public List<Integer> listGIdByUId(long uId) throws ExceptionCommonBase {
        String sql = "select g_id from t_user_game where u_id = " + uId + " order by insert_time desc";
        return this.getListInteger(sql);
    }
    
    public void delUserGameByGIdAndUId(int gId,long uId)throws ExceptionCommonBase {
        String sql = "delete from t_user_game where u_id = " + uId + " and g_id= "+gId;
        this.executeUpdate(sql);
    }
    
    
    public void delUserGameByGIdSAndUId(List<Integer> gIds,long uId)throws ExceptionCommonBase {
        String sql = "delete from t_user_game where u_id = " + uId + " and g_id in  ( "+Utils.toString(gIds) +" )";
        this.executeUpdate(sql);
    }
    
    
    public void delUserGameByGId()throws ExceptionCommonBase {
        String sql = "delete from t_user_game where g_id > 100000000";
        this.executeUpdate(sql);
    }
}
